package com.huazi.www.yang.fchua.uilt;

import java.util.List;

public class Page<T> {
    //总业数
    private int totalPageCount = 0;
    //页面总记录数
    private int pageSize = 3;
    //记录总数
    private int totalCount;
    //当前页码
    private int currPageNo = 1;
    //每页新闻集合
    private List<T> newsList;


    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        if (pageSize > 0) {
            this.pageSize = pageSize;
        }

    }

    public int getTotalCount() {
        return totalCount;
    }


    public void setTotalCount(int totalCount) {
        //传进来数据库的总记录数
        //计算总页数
        if (totalCount > 0) {
            this.totalCount = totalCount;
            totalPageCount = this.totalCount % pageSize == 0 ? (this.totalCount / pageSize) : (this.totalCount / pageSize + 1);
        }

    }

    public int getCurrPageNo() {
        if (totalPageCount == 0) {
            return 0;
        }
        return currPageNo;
    }

    public void setCurrPageNo(int currPageNo) {
        if (currPageNo > 0) {
            this.currPageNo = currPageNo;
        }
    }

    public List<T> getNewsList() {
        return newsList;
    }

    public void setNewsList(List<T> newsList) {
        this.newsList = newsList;
    }
}
